import { Module } from '@nestjs/common';
import { AuthModule } from './auth/auth.module';
import { UsersModule } from './users/users.module';
import { GoodsModule } from './goods/goods.module';
import { UnitsModule } from './units/units.module';
import { CateModule } from './cate/cate.module';
import { ClassificationModule } from './classification/classification.module';
import { UploadModule } from './upload/upload.module';
import { ServeStaticModule } from '@nestjs/serve-static';
import { join } from 'path';
import { InRecordModule } from './in-record/in-record.module';
import { SpecificationModule } from './specification/specification.module';
import { SupplierModule } from './supplier/supplier.module';
import { APP_FILTER, APP_INTERCEPTOR } from '@nestjs/core';
import { ErrorExceptionFilter } from './Exception/ErrorExceptionFilter';
import { SuccessResponseInterceptor } from './NestInterceptor';
import { StatisticsModule } from './statistics/statistics.module';

@Module({
  imports: [
    ServeStaticModule.forRoot({
      rootPath: join(__dirname, '..', 'client'),
    }),
    UsersModule,
    AuthModule,
    GoodsModule,
    UnitsModule,
    ClassificationModule,
    UploadModule,
    InRecordModule,
    SpecificationModule,
    SupplierModule,
    CateModule,
    StatisticsModule,
  ],
  controllers: [],
  providers: [
    {
      provide: APP_FILTER,
      useClass: ErrorExceptionFilter,
    },
    {
      provide: APP_INTERCEPTOR,
      useClass: SuccessResponseInterceptor,
    },
  ],
  exports: [UsersModule, GoodsModule],
})
export class AppModule {}
